package cn.tedu.d1_thread;
/**本类用来完成多线程编程实现方案二*/
public class Test2_Thread {
    public static void main(String[] args) {
        MyRunnable r=new MyRunnable();


        //把接口的实现类对象与Thread绑定
        Thread t1 = new Thread(r,"拖地");
        Thread t2 = new Thread(r,"擦桌子");
        Thread t3 = new Thread(r,"下楼倒垃圾");

        //多线程启动
        t1.start();
        t2.start();
        t3.start();


    }
}

class MyRunnable implements Runnable{

    //把业务放入run()方法,实现run()
    @Override
    public void run() {
        //写业务:打印10次，当前正在执行的线程名称
        for (int i = 0; i <10; i++) {
            System.out.println(i+"="+Thread.currentThread().getName());
        }
    }
}
